<?php
/*$this->breadcrumbs=array(
    LanguageData::t(Yii::app()->language,'Backend.Common.Menu','Manager Language'),
);*/
$this->breadcrumbs = array(
    'Manager Language Data',
);
?>

<h1>Manage Language</h1>
<div class="form wide" id="form-language">
    <?php $form = $this->beginWidget('CActiveForm', array(
    'id' => 'message-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => true,
    'clientOptions' => array(
        'validateOnSubmit' => true
    )
)); ?>

    <?php //echo $form->errorSummary($model); ?>

    <?php
    /*foreach(Yii::app()->user->getFlashes() as $key => $message) {
             echo '<div class="'. $key . 'Message">' . $message . "</div>\n";
         }*/
    ?>
    <div class="row buttons">
        <!--<input type="submit" name="export" value="<?php //echo Yii::t('Backend.Cms.ExportLanguage','Export file')?>" />
		    <input type="submit" name="delete" value="<?php //echo Yii::t('Backend.Cms.Common','Delete')?>"/>-->
        <input type="submit" name="save" value="<?php echo Yii::t('Backend.Cms.Common', 'Save'); ?>"/>
    </div>

    <div class="row message-filter-section">
        <label><?php echo Yii::t('Backend.Cms.LanguageForm', 'Language'); ?></label>
        <?php echo $form->dropDownList($model, 'lang', SourceMessage::getLanguagesList(), array('class' => 'message-filter')); ?>
    </div>

    <div class="row">
        <label><?php echo Yii::t('Backend.Cms.LanguageForm', 'Group'); ?></label>
        <?php echo $form->dropDownList($model, 'group', SourceMessage::getGroupsList(), array('class' => 'message-filter')); ?>
    </div>

    <div class="row">
        <label><?php echo Yii::t('Backend.Cms.LanguageForm', 'Module'); ?></label>
        <?php echo $form->dropDownList($model, 'module', SourceMessage::getModulesList(), array('class' => 'message-filter')); ?>
    </div>

    <div id="language-message-data">
        <?php $this->renderPartial('_language_message_data', array('lang' => $model->lang, 'group' => $model->group, 'module' => $model->module)); ?>
    </div>
    <?php $this->endWidget(); ?>
</div>

<script type="text/javascript">
    $('select.message-filter').change(function () {
        var lang = $('#SourceMessage_lang').val();
        var group = $('#SourceMessage_group').val();
        var module = $('#SourceMessage_module').val();
        $.post(
            '/index.php?r=Cms/admin/languageData/changeList',
            {
                'lang':lang,
                'group':group,
                'module':module
            },
            function (html) {
                $('#language-message-data').html(html);
            }
        );
    });
</script>